package com.lw.main;

import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

import java.awt.*;
import java.awt.image.BufferedImage;

/**
 * 云彩
 */
@AllArgsConstructor
@NoArgsConstructor
public class Cloud {

    private BufferedImage img;//云彩图片

    private int speed;//云彩速度

    private int x,y;//位置

    public void draw(Graphics g){
        x -= speed;//让云动起来
        g.drawImage(img,x,y,null);
    }

    /**
     * 用于判断云彩是否飞出了屏幕
     * @return
     */
    public boolean isOutFrame(){
        if(x<-img.getWidth()) return true;
        return false;
    }

    /**
     * 修改位置
     * @param x
     * @param y
     */
    public void changeLocation(int x,int y){
        this.x = x;
        this.y = y;
    }


}
